package com.ruslan.magaz.domain;
// default package
// Generated 28.09.2014 13:25:18 by Hibernate Tools 3.4.0.CR1

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;


/**
 * Product generated by hbm2java
 */
@Entity
@Table(name = "product", catalog = "eshop")
public class Product implements java.io.Serializable {

	private int productId;
	private Category category;
	@Size(min=2,max=20,message=	"name must be between 2 and 20 characters long.")
	@Pattern(regexp="(?U)^(\\w)*$",	message="Illegal format")
	private String name;
	@Size(min=2,max=300,message=	"Text must be between 2 and 300 characters.")
	private String description;
	@Min(0)
	@Max(100000)
	private Integer actualPrice;
	@Min(0)
	@Max(10000)
	private Integer stock;
	private Integer purchases;
	@Size(min=2,max=20,message=	"Picture name must be between 2 and 20 characters long.")
	@Pattern(regexp="(?U)^(\\w|\\.)*$",	message="Illegal format")
	private String image;
	private Set<Specification> specifications = new HashSet<Specification>(0);
	private Set<OrderedItem> ordereditems = new HashSet<OrderedItem>(0);
	private Set<Rating> ratings = new HashSet<Rating>(0);
	public Product() {
	}
	
	public Product(int productId) {
		this.productId = productId;
	}
	public Product(int productId, Category category) {
		this.productId = productId;
		this.category = category;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "Product_id", unique = true, nullable = false)
	public int getProductId() {
		return this.productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "Category_id", nullable = false)
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@Column(name = "Name", length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "Description", length = 65535)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "ActualPrice")
	public Integer getActualPrice() {
		return this.actualPrice;
	}

	public void setActualPrice(Integer actualPrice) {
		this.actualPrice = actualPrice;
	}

	@Column(name = "Stock")
	public Integer getStock() {
		return this.stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	@Column(name = "Purchases")
	public Integer getPurchases() {
		return this.purchases;
	}

	public void setPurchases(Integer purchases) {
		this.purchases = purchases;
	}

	@Column(name = "Image", length = 100)
	public String getImage() {
		return this.image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product")
	public Set<Specification> getSpecifications() {
		return this.specifications;
	}

	public void setSpecifications(Set<Specification> specifications) {
		this.specifications = specifications;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product")
	public Set<OrderedItem> getOrdereditems() {
		return this.ordereditems;
	}

	public void setOrdereditems(Set<OrderedItem> ordereditems) {
		this.ordereditems = ordereditems;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product")
	public Set<Rating> getRatings() {
		return this.ratings;
	}

	public void setRatings(Set<Rating> ratings) {
		this.ratings = ratings;
	}

}
